home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_hylafax.idb / usr / freeware / sbin / faxsetup.z / faxsetup
Encoding:
Korn shell script  |  1999-07-16  |  56.8 KB  |  2,251 lines

  1. #! /bin/ksh
  2. #    $Id: faxsetup.sh.in,v 1.34 1997/11/22 11:46:11 guru Rel $
  3. #
  4. # Warning, this file was automatically created by the HylaFAX configure script
  5. #
  6. # HylaFAX Facsimile Software
  7. #
  8. # Copyright (c) 1990-1996 Sam Leffler
  9. # Copyright (c) 1991-1996 Silicon Graphics, Inc.
  10. # HylaFAX is a trademark of Silicon Graphics
  11. # Permission to use, copy, modify, distribute, and sell this software and 
  12. # its documentation for any purpose is hereby granted without fee, provided
  13. # that (i) the above copyright notices and this permission notice appear in
  14. # all copies of the software and related documentation, and (ii) the names of
  15. # Sam Leffler and Silicon Graphics may not be used in any advertising or
  16. # publicity relating to the software without the specific, prior written
  17. # permission of Sam Leffler and Silicon Graphics.
  18. # THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  19. # EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  20. # WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  21. # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  22. # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  23. # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  24. # WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
  25. # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  26. # OF THIS SOFTWARE.
  27. #
  28.  
  29. #
  30. # VERSION:    v4.0pl2
  31. # DATE:        Thu Jun 24 10:37:27 PDT 1999
  32. # TARGET:    mips-sgi-irix6.5-ALPHA-1275645130
  33. #
  34.  
  35. #
  36. # faxsetup [options]
  37. #
  38. # This script interactively prepares and verifies 
  39. # a HylaFAX client and/or server machine for use.
  40. #
  41. PATH=/bin:/usr/bin:/etc
  42. test -d /usr/ucb  && PATH=$PATH:/usr/ucb        # Sun and others
  43. test -d /usr/bsd  && PATH=$PATH:/usr/bsd        # Silicon Graphics
  44. test -d /usr/5bin && PATH=/usr/5bin:$PATH:/usr/etc    # Sun and others
  45. test -d /usr/sbin && PATH=/usr/sbin:$PATH        # 4.4BSD-derived
  46. test -d /usr/local/bin && PATH=$PATH:/usr/local/bin    # for GNU tools
  47.  
  48. AWK=/bin/nawk            # awk for use below
  49. CAT=/bin/cat            # cat command for use below
  50. CHGRP=/bin/chgrp            # change file group for use below
  51. CHMOD=/bin/chmod            # change file mode for use below
  52. CHOWN=/bin/chown            # change file owner for use below
  53. CP=/bin/cp                # cp command for use below
  54. ECHO=/bin/echo            # echo command for use below
  55. GREP=/bin/grep            # grep command for use below
  56. LN=/bin/ln                # ln command for use below
  57. LN_S=-s            # ln option for creating a symbolic link
  58. MKFIFO=/bin/mkfifo            # FIFO creation program for use below
  59. MV=/bin/mv                # move file for use below
  60. RMCMD=/bin/rm            # remove file for use below
  61. SCRIPT_SH=/bin/ksh        # shell for use below
  62. SED=/bin/sed            # sed for use below
  63.  
  64. FAX=fax                # identity of the fax user
  65. SERVICES=/etc/services        # location of services database
  66. INETDCONF=/usr/etc/inetd.conf    # default location of inetd configuration file
  67. ALIASES=/usr/lib/aliases    # default location of mail aliases database file
  68. PASSWD=/etc/passwd        # where to go for password entries
  69. PROTOUID=uucp        # user who's uid we use for FAX user
  70. defPROTOUID=3            # use this uid if PROTOUID doesn't exist
  71. GROUP=/etc/group        # where to go for group entries
  72. PROTOGID=nuucp        # group who's gid we use for FAX user
  73. defPROTOGID=10            # use this gid if PROTOGID doesn't exist
  74.  
  75. VERSION="v4.0pl2"        # configured version
  76. DATE="Thu Jun 24 10:37:27 PDT 1999"            # data software was configured
  77. TARGET="mips-sgi-irix6.5-ALPHA-1275645130"        # configured target
  78.  
  79. DIR_AFM=/usr/lib/DPS/AFM        # directory for Adobe Font Metric files
  80. DIR_BIN=/usr/freeware/bin            # directory for client applications
  81. DIR_LIBDATA=/usr/freeware/lib/fax        # directory for client data files
  82. DIR_LIBEXEC=/usr/freeware/sbin        # directory where servers are located
  83. DIR_LOCKS=/usr/freeware/var/spool/uucp    # UUCP locking directory
  84. DIR_MAN=/usr/freeware/man        # directory for manual pages
  85. DIR_SBIN=/usr/freeware/sbin            # directory for server applications
  86. DIR_SPOOL=/usr/freeware/var/spool/fax        # top of fax spooling tree
  87.  
  88. TIFFBIN=/usr/freeware/bin        # TIFF tools
  89. LOCKS=ascii        # UUCP lock type
  90.  
  91. PATH_GETTY=/sbin/getty        # pathname for getty program
  92. PATH_SENDMAIL=/usr/lib/sendmail    # pathname for sendmail
  93. PATH_VGETTY=/bin/vgetty    # pathname for voice getty program
  94. PATH_EGETTY=/bin/egetty    # pathname for external getty program
  95.  
  96. PS=gs            # default PostScript RIP package
  97. PATH_GSRIP=/usr/freeware/bin/gs        # pathname of Ghostscript RIP
  98. PATH_DPSRIP=/usr/local/sbin/ps2fax.exe        # pathname of old IRIX DPS RIP
  99. PATH_IMPRIP=/usr/lib/print/psrip        # pathname of IRIX Impressario RIP
  100.  
  101. POSIXLY_CORRECT=1; export POSIXLY_CORRECT        # disable GNU extensions
  102.  
  103. #
  104. # These are the configuration parameters written to the
  105. # setup.cache file and read in by all the HylaFAX scripts.
  106. #
  107. # We use the same names used by configure for consistency
  108. # (but some confusion within this script).
  109. #
  110. VARS="SCRIPT_SH
  111. AFMDIR        DIR_AFM
  112. AWK
  113. BIN        DIR_BIN
  114. CAT
  115. CHGRP
  116. CHMOD
  117. CHOWN
  118. CP
  119. DPSRIP        PATH_DPSRIP
  120. ECHO
  121. GREP
  122. GSRIP        PATH_GSRIP
  123. IMPRIP        PATH_IMPRIP
  124. LIBDATA        DIR_LIBDATA
  125. LIBEXEC        DIR_LIBEXEC
  126. LN
  127. MANDIR        DIR_MAN
  128. MKFIFO
  129. MV
  130. PATH
  131. PATHGETTY    PATH_GETTY
  132. PATHVGETTY    PATH_VGETTY
  133. PATHEGETTY    PATH_EGETTY
  134. PSPACKAGE    PS
  135. RM        RMCMD
  136. SBIN        DIR_SBIN
  137. SED
  138. SENDMAIL    PATH_SENDMAIL
  139. SPOOL        DIR_SPOOL
  140. TIFFBIN
  141. UUCP_LOCKDIR    DIR_LOCKS
  142. UUCP_LOCKTYPE    LOCKS"
  143.  
  144. dumpvals()
  145. {
  146.     echo "$VARS" |
  147.     while read a b; do eval c=\$${b:-$a}; echo "$a='$c'"; done
  148. }
  149.  
  150. #
  151. # Error diagnostics that should go to the terminal are
  152. # done with this interface or cat.
  153. #
  154. bitch()
  155. {
  156.     echo "$@" 1>&2
  157. }
  158.  
  159. #
  160. # This is the preferred interface for
  161. # configure to terminate abnormally.
  162. #
  163. boom()
  164. {
  165.     $RM $JUNK
  166.     exit 1
  167. }
  168.  
  169. usage()
  170. {
  171.     cat<<EOF
  172. Usage: faxsetup [options] [host]
  173. Options: [defaults in brackets after descriptions]
  174.   -client         setup client support
  175.   -server         setup server support
  176.   -with-PARAM[=ARG]      set configuration PARAM [ARG=yes]
  177.  
  178.   -help                  print this message
  179.   -quiet                 do not print 'Using ...' messages
  180.   -verbose         opposite of -quiet
  181. EOF
  182. }
  183.  
  184. QUIET=no
  185. isServer=no
  186. isClient=no
  187.  
  188. onClient()
  189. {
  190.     test $isClient = yes
  191. }
  192. onServer()
  193. {
  194.     test $isServer = yes
  195. }
  196.  
  197. #
  198. # Crack command line arguments.  We purposely
  199. # use syntax and options that are compatible
  200. # with GNU autoconf.
  201. #
  202. WITHARGS=no
  203. ac_prev=
  204. for ac_option
  205. do
  206.     if [ -n "$ac_prev" ]; then        # assign the argument to previous option
  207.     eval "$ac_prev=\$ac_option"
  208.     ac_prev=
  209.     continue
  210.     fi
  211.     case "$ac_option" in        # collect optional argument
  212.     -*=*)    ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'`;;
  213.     *)        ac_optarg=;;
  214.     esac
  215.     case "$ac_option" in
  216.     -with-*|--with-*)
  217.     ac_with=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
  218.     # Reject names that are not valid shell variable names.
  219.     if [ -n "`echo $ac_with| sed 's/[-_a-zA-Z0-9]//g'`" ]; then
  220.         bitch "configure: $ac_with: invalid parameter name."
  221.         die
  222.     fi
  223.     ac_with=`echo $ac_with| sed 's/-/_/g'`
  224.     case "$ac_option" in
  225.     *=*)    ;;
  226.     *)    ac_optarg=yes;;
  227.     esac
  228.     eval "${ac_with}='$ac_optarg'"
  229.     WITHARGS=yes
  230.     ;;
  231.     -client)        isClient=yes;;
  232.     -server)        isServer=yes;;
  233.  
  234.     -quiet)        QUIET=yes;;
  235.     -verbose)        QUIET=no;;
  236.     -help)        usage; exit 0;;
  237.     -*)
  238.     bitch "faxsetup: $ac_option: invalid option; use -help for usage."
  239.     boom
  240.     ;;
  241.     esac
  242. done
  243.  
  244. if [ -n "$ac_prev" ]; then
  245.     bitch "faxsetup: missing argument to --`echo $ac_prev | sed 's/_/-/g'`"
  246.     boom
  247. fi
  248.  
  249. # if nothing specified on command line, default client+server
  250. if [ $isClient = no -a $isServer = no ]; then
  251.     isClient=yes
  252.     isServer=yes
  253. fi
  254.  
  255. #
  256. # Descriptor usage:
  257. # 1: ???
  258. # 2: messages that should be seen even if we're in the background.
  259. # 3: [stdout from test runs]
  260. # 4: verbose-style messages (Using ...)
  261. # 5: setup.cache file
  262. #
  263. if [ $QUIET = yes ]; then
  264.     exec 4>/dev/null            # chuck messages
  265. else
  266.     exec 4>&1                # messages go to stdout
  267. fi
  268.  
  269. Note()
  270. {
  271.     echo "$@" 1>&4
  272. }
  273.  
  274. Note ""
  275. Note "Setup program for HylaFAX (tm) $VERSION."
  276. Note ""
  277. Note "Created for $TARGET on $DATE."
  278. Note ""
  279.  
  280. CPU=`expr $TARGET : '\(.*\)-.*-.*'` || CPU=unknown
  281. VENDOR=`expr $TARGET : '.*-\(.*\)-.*'` || VENDOR=unknown
  282. OS=`expr $TARGET : '.*-.*-\([a-zA-z]*\).*'` || OS=unknown
  283. RELEASE=`(uname -r) 2>/dev/null` || RELEASE=unknown
  284.  
  285. #
  286. # Read in any site, target, vendor, os, or os-release
  287. # specific setup work.  Note that we read stuff here
  288. # so that configuration parameters can be altered.  We
  289. # use some pre-defined function names below to provide
  290. # hooks for other actions.
  291. #
  292.  
  293. #
  294. # Hooks for additional client+server checks
  295. #
  296. otherBasicServerChecks()
  297. {
  298.     true
  299. }
  300. otherBasicClientChecks()
  301. {
  302.     true
  303. }
  304. #
  305. # Hook for adding stuff to setup.modem
  306. #
  307. dumpOtherModemFuncs()
  308. {
  309.     true
  310. }
  311.  
  312. #
  313. # Figure out which brand of echo we have and define prompt
  314. # and printf shell functions accordingly.  Note that we
  315. # assume that if the System V-style echo is not present,
  316. # then the BSD printf program is available.  These functions
  317. # are defined here so that they can be tailored on a per-site,
  318. # etc. basis.
  319. #
  320. if [ `echo foo\\\c`@ = "foo@" ]; then
  321.     # System V-style echo supports \r
  322.     # and \c which is all that we need
  323.     prompt()
  324.     {
  325.        echo "$* \\c"
  326.     }
  327.     printf()
  328.     {
  329.        echo "$*\\c"
  330.     }
  331.     dumpPromptFuncs()
  332.     {
  333.     cat<<-'EOF'
  334.     prompt()
  335.     {
  336.        echo "$* \\c"
  337.     }
  338.     printf()
  339.     {
  340.        echo "$*\\c"
  341.     }
  342.     EOF
  343.     }
  344. elif [ "`echo -n foo`@" = "foo@" ]; then
  345.     # BSD-style echo; use echo -n to get
  346.     # a line without the trailing newline
  347.     prompt()
  348.     {
  349.        echo -n "$* "
  350.     }
  351.     dumpPromptFuncs()
  352.     {
  353.     cat<<-'EOF'
  354.     prompt()
  355.     {
  356.        echo -n "$* "
  357.     }
  358.     EOF
  359.     }
  360. else
  361.     # something else; do without
  362.     prompt()
  363.     {
  364.     echo "$*"
  365.     }
  366.     dumpPromptFuncs()
  367.     {
  368.     cat<<-'EOF'
  369.     prompt()
  370.     {
  371.         echo "$*"
  372.     }
  373.     EOF
  374.     }
  375. fi
  376.  
  377. if onServer; then
  378.     #
  379.     # Setup the password file manipulation functions according
  380.     # to whether we have System-V style support through the
  381.     # passmgmt program, or BSD style support through the chpass
  382.     # program, or for SCO boxes through pwconv, or SVR4 style support
  383.     # through useradd. If none are found, we setup functions that
  384.     # will cause us to abort if we need to munge the password file.
  385.     #
  386.     # NB: some systems override these function definitions through
  387.     #     per-os faxsetup files
  388.     #
  389.     if [ -f /bin/passmgmt -o -f /usr/sbin/passmgmt ]; then
  390.     addPasswd()
  391.     {
  392.         passmgmt -o -a -c 'Facsimile Agent' -h $4 -u $2 -g $3 $1
  393.     }
  394.     deletePasswd()
  395.     {
  396.         passmgmt -d $1
  397.     }
  398.     modifyPasswd()
  399.     {
  400.         passmgmt -m -h $4 -u $2 -o -g $3 $1
  401.     }
  402.     lockPasswd()
  403.     {
  404.         passwd -l $1
  405.     }
  406.     elif [ -f /usr/bin/chpass ]; then
  407.     addPasswd()
  408.     {
  409.         chpass -a "$1:*:$2:$3::0:0:Facsimile Agent:$4:"
  410.     }
  411.     modifyPasswd()
  412.     {
  413.         chpass -a "$1:*:$2:$3::0:0:Facsimile Agent:$4:"
  414.     }
  415.     lockPasswd()
  416.     {
  417.         return 0                # entries are always locked
  418.     }
  419.     elif [ -f /etc/pwconv ]; then    # could be a SCO box
  420.     addPasswd()
  421.     {
  422.         echo "${1}:NOLOGIN:${2}:${3}:Facsimile Agent:${4}:" >> ${PASSWD}
  423.         /etc/pwconv
  424.     }
  425.     lockPasswd()
  426.     {
  427.         return 0                # entries are always locked
  428.     }
  429.     elif [ -f /usr/sbin/useradd -o -f /etc/useradd ]; then
  430.     addPasswd()
  431.     {
  432.         useradd -c 'Facsimile Agent' -d $4 -u $2 -o -g $3 $1
  433.     }
  434.     deletePasswd()
  435.     {
  436.         userdel $1
  437.     }
  438.     modifyPasswd()
  439.     {
  440.         usermod -m -d $4 -u $2 -o -g $3 $1
  441.     }
  442.     lockPasswd()
  443.     {
  444.         passwd -l $1
  445.     }
  446.     else
  447.     addPasswd()
  448.     {
  449.         cat >&2 <<EOF
  450.  
  451. FATAL ERROR: I don't know how to add a passwd entry!
  452.  
  453. You will have to create the password entry manually using the following info:
  454.  
  455. Login Name: $1
  456. Password:   *
  457. Uid:        $2
  458. Gid:        $3
  459. Full Name:  Facsimile Agent
  460. Home Dir:   $4
  461.  
  462. EOF
  463.         boom
  464.     }
  465.     modifyPasswd()
  466.     {
  467.         cat >&2 <<EOF
  468.  
  469. FATAL ERROR: I don't know how to modify a passwd entry!
  470.  
  471. You will have to update the password entry manually using the following info:
  472.  
  473. Login Name: $1
  474. Password:   *
  475. Uid:        $2
  476. Gid:        $3
  477. Full Name:  Facsimile Agent
  478. Home Dir:   $4
  479.  
  480. EOF
  481.         boom
  482.     }
  483.     fi
  484.  
  485.     #
  486.     # Functions required by faxaddmodem.
  487.     #
  488.     case $TARGET in
  489.     *-sunos*|*-linux*|*-ultrix*|*-hpux*|*-freebsd*|*-netbsd*)
  490.     dumpTTYFuncs()
  491.     {
  492.         cat<<'EOF'
  493.         ttyPort()
  494.         {
  495.         expr $1 : 'tty\(.*\)'
  496.         }
  497.         ttyLocks()
  498.         {
  499.         echo $UUCP_LOCKDIR/LCK..$1
  500.         }
  501.         ttyAliases()
  502.         {
  503.         echo /dev/$1
  504.         }
  505.         ttyDev()
  506.         {
  507.         echo /dev/$1
  508.         }
  509.         checkPort()
  510.         {
  511.          return
  512.         }
  513. EOF
  514.     }
  515.     ;;
  516.     *-svr4*|*-sysv4*|*-solaris*)
  517.     dumpTTYFuncs()
  518.     {
  519.         cat<<'EOF'
  520.         ttyPort()
  521.         {
  522.         port=`expr $1 : 'term\/\(.*\)' \| $1`        # Usual
  523.         port=`expr $port : 'cua\/\(.*\)' \| $port`    # Solaris
  524.         port=`expr $port : 'tty\(.*\)' \| $port`    # Old-style
  525.         echo $port
  526.         }
  527.         ttyLocks()
  528.         {
  529.         devs=$1
  530.         locks="$UUCP_LOCKDIR/`$SVR4UULCKN /dev/$devs`" || {
  531.             echo "Sorry, I cannot determine the UUCP lock file name for $devs"
  532.             exit 1
  533.         }
  534.         echo $locks
  535.         }
  536.         ttyAliases()
  537.         {
  538.         echo /dev/$1
  539.         }
  540.         ttyDev()
  541.         {
  542.         echo /dev/$1
  543.         }
  544.         checkPort()
  545.         {
  546.          return
  547.         }
  548. EOF
  549.     }
  550.     ;;
  551.     *)
  552.     dumpTTYFuncs()
  553.     {
  554.         Note ""
  555.         Note "Beware, I am guessing the tty naming conventions for your system."
  556.         cat<<'EOF'
  557.         ttyPort()
  558.         {
  559.         expr $1 : 'tty\(.*\)'
  560.         }
  561.         ttyLocks()
  562.         {
  563.         echo $UUCP_LOCKDIR/LCK..$1
  564.         }
  565.         ttyAliases()
  566.         {
  567.         echo /dev/$1
  568.         }
  569.         ttyDev()
  570.         {
  571.         echo /dev/$1
  572.         }
  573.         checkPort()
  574.         {
  575.          return
  576.         }
  577. EOF
  578.     }
  579.     ;;
  580.     esac
  581.  
  582.     case $TARGET in
  583.     *-*bsd*)
  584.     dumpSTTYFuncs()
  585.     {
  586.         cat<<EOF
  587.         ttyStty()
  588.         {
  589.         echo $STTYCMD -f \$tdev
  590.         }
  591.         ttySpeeds()
  592.         {
  593.         speeds=
  594.         if [ -z "\$SPEED" ]; then
  595.             for s in 38400 19200 9600 4800 2400 1200; do
  596.             $STTYCMD -f \$tdev \$s </dev/null >/dev/null 2>&1 && speeds="\$speeds \$s"
  597.             done
  598.         fi
  599.         echo \$speeds
  600.         }
  601. EOF
  602.     }
  603.     ;;
  604.     *)
  605.     dumpSTTYFuncs()
  606.     {
  607.         cat<<EOF
  608.         ttyStty()
  609.         {
  610.         echo $STTYCMD
  611.         }
  612.         ttySpeeds()
  613.         {
  614.         speeds=
  615.         if [ -z "\$SPEED" ]; then
  616.             for s in 38400 19200 9600 4800 2400 1200; do
  617.             onDev $STTYCMD \$s </dev/null >/dev/null 2>&1 && speeds="\$speeds \$s"
  618.             done
  619.         fi
  620.         echo \$speeds
  621.         }
  622. EOF
  623.     }
  624.     ;;
  625.     esac
  626.  
  627.     machdepPasswdWork()
  628.     {
  629.     true
  630.     }
  631.  
  632.     #
  633.     # Default values for new scheduler config files
  634.     #
  635.     defaultLogFacility=daemon
  636.     defaultCountryCode=1
  637.     defaultAreaCode=
  638.     defaultLongDistancePrefix=1
  639.     defaultInternationalPrefix=011
  640.     defaultDialStringRules=\"etc/dialrules\"
  641.     defaultServerTracing=1
  642.     defaultContCoverPage=
  643.     defaultContCoverCmd=\"bin/mkcover\"
  644.     defaultDestControls=
  645.     defaultMaxConcurrentJobs=1
  646.     defaultMaxDials=12
  647.     defaultMaxSendPages=0xffffffff
  648.     defaultMaxTries=3
  649.     defaultModemClass=
  650.     defaultPostScriptTimeout=180
  651.     defaultPS2FaxCmd=\"bin/ps2fax\"
  652.     defaultSendFaxCmd=\"bin/faxsend\"
  653.     defaultSendPageCmd=\"bin/pagesend\"
  654.     defaultSendUUCPCmd=\"bin/uucpsend\"
  655.     defaultSessionTracing=0xffffffff
  656.     defaultTimeOfDay=\"Any\"
  657.     defaultUse2D=Yes
  658.     defaultNotifyCmd=\"bin/notify\"
  659.     defaultUUCPLockDir=\"$DIR_LOCKS\"
  660.     defaultUUCPLockTimeout=30
  661.     defaultUUCPLockType=\"$LOCKS\"
  662. fi
  663.  
  664. CONFIG_FILES=
  665. if [ -f $DIR_SBIN/faxsetup.local ]; then
  666.     . $DIR_SBIN/faxsetup.local
  667.     CONFIG_FILES="$CONFIG_FILES $DIR_SBIN/faxsetup.local"
  668. elif [ -f $DIR_SBIN/faxsetup.${CPU}-${VENDOR}-${OS}${RELEASE} ]; then
  669.     . $DIR_SBIN/faxsetup.${CPU}-${VENDOR}-${OS}${RELEASE}
  670.     CONFIG_FILES="$CONFIG_FILES $DIR_SBIN/faxsetup.${CPU}-${VENDOR}-${OS}${RELEASE}"
  671. elif [ -f $DIR_SBIN/faxsetup.${VENDOR}-${OS}${RELEASE} ]; then
  672.     . $DIR_SBIN/faxsetup.${VENDOR}-${OS}${RELEASE}
  673.     CONFIG_FILES="$CONFIG_FILES $DIR_SBIN/faxsetup.${VENDOR}-${OS}${RELEASE}"
  674. elif [ -f $DIR_SBIN/faxsetup.${CPU}-${VENDOR}-${OS} ]; then
  675.     . $DIR_SBIN/faxsetup.${CPU}-${VENDOR}-${OS}
  676.     CONFIG_FILES="$CONFIG_FILES $DIR_SBIN/faxsetup.${CPU}-${VENDOR}-${OS}"
  677. elif [ -f $DIR_SBIN/faxsetup.${VENDOR}-${OS} ]; then
  678.     . $DIR_SBIN/faxsetup.${VENDOR}-${OS}
  679.     CONFIG_FILES="$CONFIG_FILES $DIR_SBIN/faxsetup.${VENDOR}-${OS}"
  680. elif [ -f $DIR_SBIN/faxsetup.${CPU}-${VENDOR} ]; then
  681.     . $DIR_SBIN/faxsetup.${CPU}-${VENDOR}
  682.     CONFIG_FILES="$CONFIG_FILES $DIR_SBIN/faxsetup.${CPU}-${VENDOR}"
  683. elif [ -f $DIR_SBIN/faxsetup.${VENDOR} ]; then
  684.     . $DIR_SBIN/faxsetup.${VENDOR}
  685.     CONFIG_FILES="$CONFIG_FILES $DIR_SBIN/faxsetup.${VENDOR}"
  686. elif [ -f $DIR_SBIN/faxsetup.${OS} ]; then
  687.     . $DIR_SBIN/faxsetup.${OS}
  688.     CONFIG_FILES="$CONFIG_FILES $DIR_SBIN/faxsetup.${OS}"
  689. fi
  690.  
  691. #
  692. # Flush cached values if something was specified on the
  693. # command line 
  694. #
  695. if onServer; then
  696.     REASON=
  697.     if [ $WITHARGS = yes ]; then 
  698.     REASON="of command line parameters"
  699.     elif [ "$CONFIG_FILES" ]; then
  700.     REASON=`find $CONFIG_FILES -newer $DIR_SPOOL/etc/setup.cache -print 2>/dev/null`
  701.     test "$REASON" && REASON="$REASON has been updated"
  702.     fi
  703.     if [ "$REASON" -a -f $DIR_SPOOL/etc/setup.cache ]; then
  704.        Note "Flushing cached parameters because $REASON."
  705.        Note ""
  706.        rm -f $DIR_SPOOL/etc/setup.cache
  707.     fi
  708.     if [ -f $DIR_SPOOL/etc/setup.cache ]; then
  709.     Note "Reading cached parameters from $DIR_SPOOL/etc/setup.cache."
  710.     Note ""
  711.     . $DIR_SPOOL/etc/setup.cache
  712.     fi
  713. fi
  714.  
  715. RM="$RMCMD -f"                # remove file for use below
  716.  
  717. #
  718. # Deduce the effective user id:
  719. #   1. POSIX-style, the id program
  720. #   2. the old whoami program
  721. #   3. last gasp, check if we have write permission on /dev
  722. #
  723. euid=`id|$SED -e 's/.*uid=[0-9]*(\([^)]*\)).*/\1/'`
  724. test -z "$euid" && euid=`(whoami) 2>/dev/null`
  725. test -z "$euid" -a -w /dev && euid=root
  726. if [ "$euid" != "root" ]; then
  727.     bitch "Sorry, but you must run this script as the super-user!"
  728.     boom
  729. fi
  730.  
  731. onClient && Note "Checking system for proper client configuration."
  732. onServer && Note "Checking system for proper server configuration."
  733.  
  734. #
  735. # Verify configuration parameters are correct.
  736. #
  737.  
  738. dirMisConfigured()
  739. {
  740.    cat >&2 <<EOF
  741.  
  742. FATAL ERROR: $1 does not exist or is not a directory!
  743.  
  744. The directory $1 does not exist or this file is not a directory.  If
  745. the HylaFAX software is not yet installed you must do so before running
  746. this script.  If the software is installed but is configured for use in
  747. a different location than this script expects then the software will not
  748. function correctly.
  749.  
  750. EOF
  751.    boom
  752. }
  753.  
  754. #
  755. # Check basic spooling area setup.
  756. #
  757. if onServer; then
  758.     test -d $DIR_SPOOL || {
  759.     cat >&2 <<-EOF
  760.  
  761.     FATAL ERROR: $DIR_SPOOL does not exist or is not a directory!
  762.  
  763.     The HylaFAX spooling area $DIR_SPOOL does not exist or this file is
  764.     not a directory.  If the HylaFAX software is not yet installed you
  765.     must do so before running this script.  If the software is installed
  766.     but is configured for use in a different location than this script
  767.     expects then you may override the default pathname by running this
  768.     script with a -with-DIR_SPOOL option; e.g.
  769.  
  770.     faxsetup -with-DIR_SPOOL=/var/spool/someplace_unexpected
  771.  
  772.     EOF
  773.     boom
  774.     }
  775.     cd $DIR_SPOOL
  776.     DIRS="archive bin client config dev docq doneq etc info log\
  777.     pollq recvq sendq status tmp"
  778.     for i in $DIRS; do
  779.     test -d $i || dirMisConfigured $DIR_SPOOL/$i
  780.     done
  781.     #
  782.     # XXX should check permission and ownership of sensitive dirs
  783.     #
  784.  
  785.     JUNK="etc/setup.tmp"
  786.     trap "$RM \$JUNK; exit 1" 1 2 15
  787.  
  788.     exec 5>etc/setup.tmp
  789.     echo '# Warning, this file was automatically generated by faxsetup' >&5
  790.     echo '# on' `date` "for ${USER:-$euid}" >&5
  791. fi
  792.  
  793. #
  794. # Basic client installation.
  795. #
  796. if onClient; then
  797.     test -d $DIR_BIN     || dirMisConfigured $DIR_BIN
  798.     for file in sendfax sendpage faxstat faxalter faxcover faxmail faxrm; do
  799.     test -x $DIR_BIN/$file || {
  800.         cat >&2 <<EOF
  801.  
  802. FATAL ERROR: $DIR_BIN/$file is not an executable program!
  803.  
  804. The file $DIR_BIN/$file does not exist or this file is not
  805. an executable program.  If the HylaFAX software is not yet installed you
  806. must do so before running this script.  If the software is installed but
  807. is configured for use in a different location than this script expects
  808. then the software will not function correctly.
  809.  
  810. EOF
  811.        boom
  812.     }
  813.     done
  814.     test -d $DIR_LIBDATA || dirMisConfigured $DIR_LIBDATA
  815.     for file in pagesizes faxcover.ps typerules; do
  816.     test -f $DIR_LIBDATA/$file || {
  817.         cat >&2 <<EOF
  818.  
  819. FATAL ERROR: $DIR_LIBDATA/$file does not exist!
  820.  
  821. The file $DIR_LIBDATA/$file does not exist.  If the HylaFAX
  822. software is not yet installed you must do so before running this script.
  823. If the software is installed but is configured for use in a different
  824. location than this script expects then the software will not function
  825. correctly.
  826.  
  827. EOF
  828.        boom
  829.     }
  830.     done
  831.     test -d $DIR_LIBEXEC || dirMisConfigured $DIR_LIBEXEC
  832.     for file in textfmt; do
  833.     test -f $DIR_LIBEXEC/$file || {
  834.         cat >&2 <<EOF
  835.  
  836. FATAL ERROR: $DIR_LIBEXEC/$file does not exist!
  837.  
  838. The file $DIR_LIBEXEC/$file does not exist.  If the HylaFAX
  839. software is not yet installed you must do so before running this script.
  840. If the software is installed but is configured for use in a different
  841. location than this script expects then the software will not function
  842. correctly.
  843.  
  844. EOF
  845.        boom
  846.     }
  847.     done
  848.  
  849.     otherBasicClientChecks
  850. fi
  851.  
  852. #
  853. # Server setup other than the spooling area.
  854. #
  855. if onServer; then
  856.     test -d $DIR_LIBEXEC || dirMisConfigured $DIR_LIBEXEC
  857.     test -d $DIR_SBIN     || dirMisConfigured $DIR_SBIN
  858.     test -d $DIR_LOCKS   || {
  859.        cat >&2 <<EOF
  860.  
  861. FATAL ERROR: $DIR_LOCKS does not exist or is not a directory!
  862.  
  863. The UUCP lockfile directory is not where it is expected or this file
  864. is not a directory.  It is possible to configure the HylaFAX software
  865. to use a directory other than the configured one by setting up the
  866. UUCPLockDir configuration parameter in each configuration file in the
  867. $DIR_SPOOL/etc directory, but this is potentially error-prone.
  868. Your best bet is to either create a symbolic link for the expected
  869. pathname or reconfigure HylaFAX with the correct pathname and build
  870. a new distribution.
  871. EOF
  872.     boom
  873.     }
  874.     test -d $TIFFBIN    || {
  875.     cat >&2 <<EOF
  876.  
  877. FATAL ERROR: $TIFFBIN does not exist or is not a directory!
  878.  
  879. The directory of tools from the TIFF software distribution is not
  880. where it is expected or this file is not a directory.  If you do not
  881. have the TIFF distribution installed on this machine then you must
  882. install it; the master FTP location is ftp://ftp.sgi.com/graphics/tiff.
  883. Otherwise, if the software is installed in a directory other than
  884. where it is expected you can configure the HylaFAX software to use
  885. an alternate directory by supplying a -with-TIFFBIN option when running
  886. this script; e.g. faxsetup -with-TIFFBIN=someplace_nonstandard.
  887.  
  888. EOF
  889.     boom
  890.     }
  891.     for file in tiffcp tiff2ps fax2ps tiffinfo; do
  892.     test -x $TIFFBIN/$file    || {
  893.         cat >&2 <<EOF
  894.  
  895. FATAL ERROR: $TIFFBIN/$file does not exist or is not an executable program!
  896.  
  897. The program $TIFFBIN/$file is not where it is expected or the file
  898. is not executable.  This program is part of the TIFF software
  899. distribution that is required for use with HylaFAX.  If you do not
  900. have the TIFF distribution installed on this machine then you must
  901. install it; the master FTP location is ftp://ftp.sgi.com/graphics/tiff.
  902. Otherwise, if the software is installed in a directory other than
  903. where it is expected you can configure the HylaFAX software to use
  904. an alternate directory by supplying a -with-TIFFBIN option when running
  905. this script; e.g.  faxsetup -with-TIFFBIN=someplace_nonstandard.
  906.  
  907. EOF
  908.         boom
  909.     }
  910.     done
  911.  
  912.     otherBasicServerChecks
  913. fi
  914.  
  915. #
  916. # Quick check to see if the manual pages are installed;
  917. # perhaps not even worth the effort.
  918. #
  919. test -d $DIR_MAN || {
  920.     cat >&4 <<EOF
  921.  
  922.  
  923. Warning: $DIR_MAN does not exist or is not a directory!
  924.  
  925. The directory for manual pages does not exist or is not a directory.
  926. If this directory does not exist because the manual pages have not been
  927. installed then you can ignore this message.  Otherwise you may want to
  928. check out what happened to the manual pages.
  929. EOF
  930. }
  931.  
  932. #
  933. # Utility program parameters.
  934. #
  935. appMisConfigured()
  936. {
  937.    cat >&2 <<EOF
  938.  
  939. FATAL ERROR: $1 does not exist or is not an executable program!
  940.  
  941. The file:
  942.  
  943.     $1
  944.  
  945. does not exist or this file is not an executable program.  The HylaFAX
  946. software expects this program to exist and be in this location.  If the
  947. program resides in a different location then you must either reconfigure
  948. and rebuild HylaFAX or override the default pathnames in the distributed
  949. software through one of the HylaFAX configuration files (consult the
  950. HylaFAX documentation).
  951.  
  952. EOF
  953.    boom
  954. }
  955. warnAppMisConfigured()
  956. {
  957.    cat >&2 <<EOF
  958.  
  959.  
  960. Warning: $1 does not exist or is not an executable program!
  961.  
  962. The file:
  963.  
  964.     $1
  965.  
  966. does not exist or this file is not an executable program.  The
  967. HylaFAX software optionally uses this program and the fact that
  968. it does not exist on the system is not a fatal error.  If the
  969. program resides in a different location and you do not want to
  970. install a symbolic link for $1 that points to your program
  971. then you must reconfigure and rebuild HylaFAX from source code.
  972. EOF
  973. }
  974.  
  975. if onServer; then
  976.     test -x $PATH_GETTY        || warnAppMisConfigured $PATH_GETTY
  977.     test -x $PATH_VGETTY    || warnAppMisConfigured $PATH_VGETTY
  978.     test -x $PATH_EGETTY    || warnAppMisConfigured $PATH_EGETTY
  979.  
  980.     for i in $CAT $CHGRP $CHMOD $CHOWN $CP $ECHO $GREP $LN $MKFIFO $MV \
  981.     $RMCMD $SED $SENDMAIL; do
  982.     test -x $i || appMisConfigured $i
  983.     done
  984.  
  985.     #
  986.     # Test/verify we know how to create FIFO special files.
  987.     #
  988.     case $MKFIFO in
  989.     *mknod)
  990.     mkfifo()
  991.     {
  992.         $MKFIFO $1 p
  993.     }
  994.     ;;
  995.     *)
  996.     mkfifo()
  997.     {
  998.         $MKFIFO $1
  999.     }
  1000.     ;;
  1001.     esac
  1002.     $RM conffifo; JUNK="$JUNK conffifo"
  1003.     if (mkfifo conffifo && test -p conffifo) >/dev/null 2>&1; then
  1004.     true
  1005.     elif test -r conffifo; then            # NB: not everyone has test -p
  1006.     true
  1007.     else
  1008.     cat >&2 <<EOF
  1009.  
  1010. FATAL ERROR: Don't know how to create FIFO special files!
  1011.  
  1012. We were unable to create a FIFO special file using the command:
  1013.  
  1014.      $MKFIFO conffifo
  1015.  
  1016. HylaFAX requires support for FIFO special files and will not function
  1017. without this support.  If your system does not have support for FIFO
  1018. files then reconfigure it to include support (on some systems this
  1019. support is optional and requires recompilation or rebuilding of the
  1020. kernel).  If your system does have support for FIFO files but they are
  1021. not created using the expected program then you will need to reconfigure
  1022. and rebuild HylaFAX from the source distribution or emulate the needed
  1023. functionality (possibly by providing a shell script).
  1024.  
  1025. EOF
  1026.     boom
  1027.     fi
  1028. fi
  1029.  
  1030. #
  1031. # AWK support.
  1032. #
  1033. if onServer; then
  1034.     test -x $AWK        || appMisConfigured $AWK
  1035.     # awk must support functions and -v
  1036.     CheckAwk()
  1037.     {
  1038.     ($1 -v BAR=bar '
  1039.     function foo(x) {
  1040.     print "GOT" x
  1041.     }
  1042.     BEGIN { foo(BAR) }
  1043.     ' </dev/null | grep GOTbar) >/dev/null 2>&1
  1044.     return
  1045.     }
  1046.     CheckAwk $AWK || {
  1047.     cat >&2 <<EOF
  1048.  
  1049. FATAL ERROR: $AWK does not support needed functionality!
  1050.  
  1051. The following test does not work correctly with the configured awk program.
  1052.  
  1053. ----------------------------------------------------------
  1054. $AWK -v BAR=bar '
  1055. function foo(x) {
  1056. print "GOT" x
  1057. }
  1058. BEGIN { foo(BAR) }
  1059. ' </dev/null | grep GOTbar
  1060. ----------------------------------------------------------
  1061.  
  1062. The HylaFAX software requires an awk program that supports functions and
  1063. the -v option for passing parameters from the command line.  The deficiency
  1064. of $AWK on your system will cause problems in various parts of the HylaFAX
  1065. software.
  1066.  
  1067. If you are running an old version of $AWK then get a more up to date
  1068. version.  Otherwise you can reconfigure HylaFAX from the source distribution
  1069. to force a different awk program to be used or you can, as a last resort,
  1070. try altering the shell scripts that are part of HylaFAX that use $AWK.
  1071.  
  1072. EOF
  1073.     boom
  1074.     }
  1075. fi
  1076.  
  1077. #
  1078. # Installation of Adobe Font Metric files
  1079. #
  1080. if onClient; then
  1081.     if [ -d $DIR_AFM ]; then
  1082.     if [ ! -f $DIR_AFM/Courier ] && [ ! -f $DIR_AFM/Courier.afm ]; then
  1083.         cat >&4 <<EOF
  1084.  
  1085.  
  1086. Warning: Font metric information files were not found!
  1087.  
  1088. The font metric information file for the Courier font was not found in
  1089. the $DIR_AFM directory.  This means that client HylaFAX applications 
  1090. that use this information to format ASCII text for submission as fax will
  1091. use incorrect information and generate potentially illegible facsimile.
  1092.  
  1093. If font metric information is present on your system in a directory other
  1094. than $DIR_AFM then you can setup a symbolic link to the appropriate
  1095. directory or you can specify the appropriate pathname in the configuration
  1096. file $DIR_LIBDATA/hyla.conf with a line of the form:
  1097.  
  1098. FontDir:    someplace_unexpected
  1099.  
  1100. If you do not have the font metric information files loaded on your system
  1101. system you can obtain them by public FTP from the place where you obtained
  1102. the HylaFAX software or from the master FTP site at ftp.sgi.com.
  1103. EOF
  1104.     fi
  1105.     else
  1106.     cat >&4 <<EOF
  1107.  
  1108.  
  1109. Warning: $DIR_AFM does not exist or is not a directory!
  1110.  
  1111. The directory $DIR_AFM does not exist or this file is not a directory.
  1112. This is the directory where the HylaFAX client applications expect to
  1113. locate font metric information to use in formatting ASCII text for
  1114. submission as facsimile.  Without this information HylaFAX may generate
  1115. illegible facsimile from ASCII text.
  1116.  
  1117. If font metric information is present on your system in a directory other
  1118. than $DIR_AFM then you can setup a symbolic link to the appropriate
  1119. directory or you can specify the appropriate pathname in the configuration
  1120. file $DIR_LIBDATA/hyla.conf with a line of the form:
  1121.  
  1122. FontDir:    someplace_unexpected
  1123.  
  1124. If you do not have the font metric information files loaded on your system
  1125. system you can obtain them by public FTP from the place where you obtained
  1126. the HylaFAX software or from the master FTP site at ftp.sgi.com.
  1127. EOF
  1128.     fi
  1129. fi
  1130.  
  1131. #
  1132. # PostScript RIP support.
  1133. #
  1134. if onServer; then
  1135.     case $PS in
  1136.     dps)    PATH_PSRIP=$PATH_DPSRIP;;
  1137.     imp)    PATH_PSRIP=$PATH_IMPRIP;;
  1138.     gs)        PATH_PSRIP=$PATH_GSRIP;;
  1139.     esac
  1140.     if [ -x "$PATH_PSRIP" ]; then
  1141.     if [ $PS = gs ]; then
  1142.         # verify Ghostscript was linked with the tiffg3 device driver
  1143.         $PATH_PSRIP -h | grep tiffg3 >/dev/null 2>&1 || {
  1144.         cat >&2 <<EOF
  1145.  
  1146. FATAL ERROR: No tiffg3 driver in $PATH_PSRIP.
  1147.  
  1148. HylaFAX has been configured to use Ghostscript as the PostScript
  1149. imaging program but the output of $PATH_PSRIP -h does not
  1150. list the tiffg3 driver as a configured driver (see below).
  1151.  
  1152. ----------------------------------------------------------
  1153. % $PATH_PSRIP -h
  1154. EOF
  1155. $PATH_PSRIP -h
  1156. ----------------------------------------------------------
  1157.         cat >&2 <<EOF
  1158.  
  1159. The tiffg3 driver is required for HylaFAX to operate correctly. 
  1160. Consult the documentation for information on building Ghostscript
  1161. with the necessary TIFF driver and then rerun faxsetup when a new
  1162. Ghostscript has been installed.
  1163.  
  1164. EOF
  1165.         boom
  1166.         }
  1167.     elif [ $PS = dps ]; then
  1168.         JUNK="$JUNK ps.fax"
  1169.         $CAT etc/dpsprinter.ps | $PATH_PSRIP >/dev/null 2>&1
  1170.         if [ $? -eq 2 ]; then
  1171.         if expr $RELEASE \>= 6.2 >/dev/null; then
  1172.             cat >&2 <<EOF
  1173.  
  1174. FATAL ERROR: No DPS-based RIP available for IRIX $RELEASE!
  1175.  
  1176. The DPS-based PostScript RIP is a COFF executable and cannot be used
  1177. under IRIX $RELEASE.  You must use a different RIP such as fw_gs.sw.gs
  1178. which is found on the SGI Freeware CD-ROM and which is based on the
  1179. freely distributed Ghostscript software package.  This package is
  1180. also included in the binary distribution of HylaFAX for SGI systems
  1181. found on ftp.sgi.com.
  1182.  
  1183. Once you have installed the Ghostscript distribution rerun faxsetup
  1184. with the option -with-PS=gs to override the default setting.
  1185.  
  1186. EOF
  1187.             boom
  1188.         fi
  1189.         fi
  1190.     fi
  1191.     elif [ $PS = dps ]; then
  1192.     if expr $RELEASE \>= 6.2 >/dev/null; then
  1193.         cat >&2 <<EOF
  1194.  
  1195. FATAL ERROR: No DPS-based RIP available for IRIX $RELEASE!
  1196.  
  1197. This distribution has been configured to use the DPS-based PostScript
  1198. RIP that is only available as a COFF executable.  This program cannot
  1199. be used under IRIX $RELEASE.  You must use a different RIP such as the
  1200. Ghostscript-based RIP in the fw_gs.sw.gs installation image which is
  1201. found on the SGI Freeware CD-ROM.  The fw_gs package is also included
  1202. in the binary distribution of HylaFAX for SGI systems found on ftp.sgi.com.
  1203.  
  1204. Once you have installed the Ghostscript distribution rerun faxsetup
  1205. with the option -with-PS=gs to override the default setting.
  1206.  
  1207. EOF
  1208.         boom
  1209.     else
  1210.         appMisConfigured $PATH_PSRIP
  1211.     fi
  1212.     else
  1213.     appMisConfigured $PATH_PSRIP
  1214.     fi
  1215.     #
  1216.     # Force bin/ps2fax to point to the appropriate script.
  1217.     #
  1218.     Note ""
  1219.     Note "Make $DIR_SPOOL/bin/ps2fax a link to $DIR_SPOOL/bin/ps2fax.$PS."
  1220.     Note ""
  1221.     $RM bin/ps2fax
  1222.     if [ -n "$LN_S" ]; then
  1223.     $LN $LN_S ps2fax.$PS bin/ps2fax;
  1224.     else
  1225.     $LN bin/ps2fax.$PS bin/ps2fax;
  1226.     fi
  1227. fi
  1228.  
  1229. #
  1230. # Find the full pathname of a file
  1231. # using the specified test operation.
  1232. #
  1233. findThing()
  1234. {
  1235.     t="$1"; app=$2; path=$3;
  1236.     case $app in
  1237.     /*) eval $t $app && { echo $app; return; };;
  1238.     esac
  1239.     IFS=:
  1240.     for i in $path; do
  1241.     eval $t $i/$app && { echo $i/$app; return; }
  1242.     done
  1243. }
  1244.  
  1245. #
  1246. # Find the full pathname of an executable.
  1247. #
  1248. findApp()
  1249. {
  1250.     findThing "test -x" $1 $2
  1251. }
  1252.  
  1253. #
  1254. # Deal with known alternate locations for system files.
  1255. #
  1256. PickFile()
  1257. {
  1258.     for i do
  1259.     test -f $i && { echo $i; return; }
  1260.     done
  1261.     echo $1
  1262. }
  1263.  
  1264. INETDCONF=`PickFile    $INETDCONF /etc/inetd.conf /etc/inet/inetd.conf`
  1265. ALIASES=`PickFile    $ALIASES   /etc/aliases /etc/ucbmail/aliases /usr/mmdf/table/alias.user /usr/mmdf/table/alias.n`
  1266. SERVICES=`PickFile    $SERVICES  /etc/inet/services`
  1267. test -f /etc/master.passwd    && PASSWD=/etc/master.passwd
  1268.  
  1269. #
  1270. # Figure out which brand of echo we have and define
  1271. # prompt and printf shell functions accordingly.
  1272. # Note that we assume that if the System V-style
  1273. # echo is not present, then the BSD printf program
  1274. # is available.
  1275. #
  1276. t=`(printf hello) 2>/dev/null`
  1277. if [ "$t" != hello ]; then
  1278.     cat >&2 <<EOF
  1279.  
  1280. FATAL ERROR: No printf command or emulation!
  1281.  
  1282. HylaFAX requires a shell-level program that understands C-style strings
  1283. (e.g. "\r") and has a mechanism for printing a string without a trailing
  1284. newline character.  The System V echo command and the BSD/POSIX-style
  1285. printf command are known to support these functions;  however your system
  1286. does not appear to have either of these programs.  If you have a program
  1287. hidden somewhere on your system be sure to include it in the search path
  1288. used by faxsetup:
  1289.  
  1290.     $PATH
  1291.  
  1292. and then rerun faxsetup.  Otherwise a printf command is included in the
  1293. GNU shell utilities package that can be retrieved by public FTP.
  1294.  
  1295. EOF
  1296.     boom
  1297. fi
  1298. if onServer; then
  1299.     dumpPromptFuncs >&5
  1300. fi
  1301.  
  1302. #
  1303. # Prompt the user for a string that can not be null.
  1304. #
  1305. promptForNonNullStringParameter()
  1306. {
  1307.     x=""
  1308.     while [ -z "$x" ]; do
  1309.     prompt "$2 [$1]?"; read x
  1310.     if [ "$x" ]; then
  1311.         # strip leading and trailing white space
  1312.         x=`echo "$x" | $SED -e 's/^[     ]*//' -e 's/[     ]*$//'`
  1313.     else
  1314.         x="$1"
  1315.     fi
  1316.     done
  1317.     param="$x"
  1318. }
  1319.  
  1320. #
  1321. # Prompt the user for a string that can be null.
  1322. #
  1323. promptForStringParameter()
  1324. {
  1325.     prompt "$2 [$1]?"; read x
  1326.     if [ "$x" ]; then
  1327.     # strip leading and trailing white space
  1328.     x=`echo "$x" | $SED -e 's/^[     ]*//' -e 's/[     ]*$//'`
  1329.     else
  1330.     x="$1"
  1331.     fi
  1332.     param="$x"
  1333. }
  1334.  
  1335. #
  1336. # Prompt the user for a numeric value.
  1337. #
  1338. promptForNumericParameter()
  1339. {
  1340.     x=""
  1341.     while [ -z "$x" ]; do
  1342.     prompt "$2 [$1]?"; read x
  1343.     if [ "$x" ]; then
  1344.         # strip leading and trailing white space
  1345.         x=`echo "$x" | $SED -e 's/^[     ]*//' -e 's/[     ]*$//'`
  1346.         match=`expr "$x" : "\([0-9]*\)"`
  1347.         if [ "$match" != "$x" ]; then
  1348.         echo ""
  1349.         echo "This must be entirely numeric; please correct it."
  1350.         echo ""
  1351.         x="";
  1352.         fi
  1353.     else
  1354.         x="$1"
  1355.     fi
  1356.     done
  1357.     param="$x"
  1358. }
  1359.  
  1360. #
  1361. # Prompt the user for a C-style numeric value.
  1362. #
  1363. promptForCStyleNumericParameter()
  1364. {
  1365.     x=""
  1366.     while [ -z "$x" ]; do
  1367.     prompt "$2 [$1]?"; read x
  1368.     if [ "$x" ]; then
  1369.         # strip leading and trailing white space and C-style 0x prefix
  1370.         x=`echo "$x" | $SED -e 's/^[     ]*//' -e 's/[     ]*$//'`
  1371.         match=`expr "$x" : "\([0-9]*\)" \| "$x" : "\(0x[0-9a-fA-F]*\)"`
  1372.         if [ "$match" != "$x" ]; then
  1373.         echo ""
  1374.         echo "This must be entirely numeric; please correct it."
  1375.         echo ""
  1376.         x="";
  1377.         fi
  1378.     else
  1379.         x="$1"
  1380.     fi
  1381.     done
  1382.     param="$x"
  1383. }
  1384.  
  1385. #
  1386. # Prompt the user for a boolean value.
  1387. #
  1388. promptForBooleanParameter()
  1389. {
  1390.     x=""
  1391.     while [ -z "$x" ]; do
  1392.     prompt "$2 [$1]?"; read x
  1393.     if [ "$x" ]; then
  1394.         # strip leading and trailing white space
  1395.         x=`echo "$x" | $SED -e 's/^[     ]*//' -e 's/[     ]*$//'`
  1396.         case "$x" in
  1397.         n|no|off)    x=no;;
  1398.         y|yes|on)    x=yes;;
  1399.         *)
  1400. cat <<EOF
  1401.  
  1402. "$x" is not a valid boolean parameter setting;
  1403. use one of: "yes", "on", "no", or "off".
  1404. EOF
  1405.         x="";;
  1406.         esac
  1407.     else
  1408.         x="$1"
  1409.     fi
  1410.     done
  1411.     param="$x"
  1412. }
  1413.  
  1414. #
  1415. # Compile a table of configuration parameters prompts into
  1416. # a shell program that can be ``eval'd'' to prompt the user
  1417. # for changes to the current parameter settings.
  1418. #
  1419. compilePrompts()
  1420. {
  1421.     $AWK -F'[    ]+' '
  1422. function p(t)
  1423. {
  1424.     printf "promptFor%sParameter \"$%s\" \"%s\";%s=\"$param\"\n", t, $2, $3, $2
  1425. }
  1426. $1 == "#"    { p("Numeric"); next }
  1427. $1 == "C#"    { p("CStyleNumeric"); next }
  1428. $1 == "S"    { p("String"); next }
  1429. $1 == "NNS"    { p("NonNullString"); next }
  1430. $1 == "B"    { p("Boolean"); next }
  1431.         { printf "promptFor%s\n", $1 }
  1432. '
  1433. }
  1434.  
  1435. faxUID=`grep "^$PROTOUID:" $PASSWD | cut -d: -f3`
  1436. if [ -z "$faxUID" ]; then faxUID=$defPROTOUID; fi
  1437. faxGID=`grep "^$PROTOGID:" $GROUP | cut -d: -f3`
  1438. if [ -z "$faxGID" ]; then faxGID=$defPROTOGID; fi
  1439.  
  1440. #
  1441. # Change the password file entry for the fax user.
  1442. #
  1443. fixupFaxUser()
  1444. {
  1445.     emsg1=`modifyPasswd $FAX $faxUID $faxGID $DIR_SPOOL 2>&1`
  1446.     case $? in
  1447.     0)    echo "Done, the \"$FAX\" user should now have the right user id.";;
  1448.     *) cat <<-EOF
  1449.  
  1450.     FATAL ERROR: Command failed!
  1451.  
  1452.     The modify password command failed with the message:
  1453.  
  1454.     "$emsg1"
  1455.  
  1456.     HylaFAX will not work correctly until the proper uid is setup
  1457.     for it in the password file.  Please fix this problem and then
  1458.     rerun faxsetup.
  1459.  
  1460.     EOF
  1461.     boom
  1462.     ;;
  1463.     esac
  1464. }
  1465.  
  1466. #
  1467. # Add a fax user to the password file and lock the
  1468. # entry so that noone can login as the user.
  1469. #
  1470. addFaxUser()
  1471. {
  1472.     emsg1=`addPasswd $FAX $faxUID $faxGID $DIR_SPOOL 2>&1`
  1473.     case $? in
  1474.     0)  emsg2=`lockPasswd $FAX 2>&1`
  1475.     case $? in
  1476.     0) echo "Added user \"$FAX\" to $PASSWD.";;
  1477.     *) emsg3=`deletePasswd $FAX 2>&1`
  1478.        case $? in
  1479.        0|9) cat <<-EOF
  1480.  
  1481.         Failed to add user "$FAX" to $PASSWD because the
  1482.         attempt to lock the password failed with:
  1483.  
  1484.         "$emsg2"
  1485.  
  1486.         Please fix this problem and rerun this script."
  1487.  
  1488.         EOF
  1489.         ;;
  1490.        *)   cat <<-EOF
  1491.  
  1492.         You will have to manually edit $PASSWD because
  1493.         after successfully adding the new user "$FAX", the
  1494.         attempt to lock its password failed with:
  1495.  
  1496.         "$emsg2"
  1497.  
  1498.         and the attempt to delete the insecure passwd entry failed with:
  1499.  
  1500.         "$emsg3"
  1501.  
  1502.         To close this security hole, you should add a password
  1503.         to the "$FAX" entry in the file $PASSWD, or lock this
  1504.         entry with an invalid password.
  1505.  
  1506.         EOF
  1507.         ;;
  1508.         esac
  1509.         boom;;
  1510.     esac;;
  1511.     9)  # fax was already in $PASSWD, but not found with grep
  1512.     ;;
  1513.     *)  cat <<-EOF
  1514.  
  1515.     There was a problem adding user "$FAX" to $PASSWD;
  1516.     the command failed with:
  1517.  
  1518.     "$emsg1"
  1519.  
  1520.     HylaFAX will not work until you have corrected this problem.
  1521.  
  1522.     EOF
  1523.     boom;;
  1524.     esac
  1525. }
  1526.  
  1527. isOK()
  1528. {
  1529.     x="$1"
  1530.     test -z "$x" -o "$x" = y -o "$x" = yes
  1531. }
  1532.  
  1533. if onServer; then
  1534.     x=`grep "^$FAX:" $PASSWD | cut -d: -f3`
  1535.     if [ -z "$x" ]; then
  1536.     echo ""
  1537.     echo ""
  1538.     echo "You do not appear to have a \"$FAX\" user in the password file."
  1539.     prompt "HylaFAX needs this to work properly, add it [yes]?"
  1540.     read x
  1541.     isOK $x && addFaxUser
  1542.     elif [ "$x" != "$faxUID" ]; then
  1543.     echo ""
  1544.     echo ""
  1545.     echo "It looks like you have a \"$FAX\" user in the password file,"
  1546.     echo "but with a uid different than the uid for uucp.  You probably"
  1547.     echo "have old fax software installed.  In order for this software"
  1548.     echo "to work properly, the fax user uid must be the same as uucp."
  1549.     prompt "Is it ok to change the password entry for \"$FAX\" [yes]?"
  1550.     read x;
  1551.     isOK $x && fixupFaxUser
  1552.     fi
  1553.     machdepPasswdWork
  1554.  
  1555.     #
  1556.     # Verify existence, permission and ownership of sensitive files.
  1557.     # XXX there are other files too 
  1558.     #
  1559.     HOSTS=$DIR_SPOOL/etc/hosts
  1560.     test -f $HOSTS || {
  1561.     cat<<EOF
  1562.  
  1563. Warning: $1 does not exist!
  1564.  
  1565. The file $1 does not exist or is not a regular file.
  1566. This file specifies which clients are permitted to use the HylaFAX
  1567. server.  The file will be initialized so that local clients are
  1568. provided service.  Consult the HTML documentation and the manual
  1569. page hosts(4F) for more information on setting up this file.
  1570.  
  1571. EOF
  1572.     $RM $HOSTS
  1573.     echo "localhost" >$HOSTS
  1574.     echo "127.0.0.1" >>$HOSTS
  1575.     }
  1576.     #
  1577.     # Too complicated to check contents:
  1578.     # simply force correct protection and ownership
  1579.     #
  1580.     $CHOWN $faxUID $HOSTS; $CHGRP $faxGID $HOSTS
  1581.     $CHMOD 600 $HOSTS
  1582. fi
  1583.  
  1584. #
  1585. # Check for services entries for hylafax and snpp.
  1586. #
  1587. hasYP=`(ypcat services) 2>/dev/null | tail -1` 2>/dev/null
  1588. x=`$GREP '^hylafax[     ]' $SERVICES 2>/dev/null` 2>/dev/null
  1589. if [ -z "$x" ]; then
  1590.     if [ "$hasYP" ]; then
  1591.     x=`ypcat services 2>/dev/null | $GREP '^hylafax[     ]'` 2>/dev/null
  1592.     fi
  1593.     if [ -z "$x" ]; then
  1594.     ENTRY="hylafax    4559/tcp        # HylaFAX client-server protocol"
  1595.     cat<<-EOF
  1596.  
  1597.  
  1598.     Warning: No hylafax service entry found!
  1599.  
  1600.     No entry was found for the hylafax service in the YP/NIS database
  1601.     or in the $SERVICES file.  The software should work properly
  1602.     without one (except if you want to start hfaxd from inetd), but you
  1603.     will see warning messages whenever you run a HylaFAX client
  1604.     application.  If you want to manually add an entry the following
  1605.     information should be used:
  1606.  
  1607.     $ENTRY
  1608.  
  1609.     EOF
  1610.     prompt "Should a hylafax entry be added to $SERVICES [yes]?"
  1611.     read x
  1612.     isOK $x && echo "$ENTRY" >>$SERVICES
  1613.     fi
  1614. fi
  1615. x=`$GREP '^snpp[     ]' $SERVICES 2>/dev/null` 2>/dev/null
  1616. if [ -z "$x" ]; then
  1617.     if [ "$hasYP" ]; then
  1618.     x=`ypcat services 2>/dev/null | $GREP '^snpp[     ]'` 2>/dev/null
  1619.     fi
  1620.     if [ -z "$x" ]; then
  1621.     ENTRY="snpp    444/tcp        # Simple Network Paging Protocol"
  1622.     cat<<-EOF
  1623.  
  1624.  
  1625.     Warning: No snpp service entry found!
  1626.  
  1627.     No entry was found for the Simple Network Paging Protocol (SNPP)
  1628.     service in the YP/NIS database or in the $SERVICES file.
  1629.     The software should work properly without one (except if you want
  1630.     to start hfaxd from inetd), but you will see warning messages whenever
  1631.     you run the HylaFAX sendpage program.  If you want to manually add
  1632.     an entry the following information should be used:
  1633.  
  1634.     $ENTRY
  1635.  
  1636.     EOF
  1637.     prompt "Should an snpp entry be added to $SERVICES [yes]?"
  1638.     read x
  1639.     isOK $x && echo "$ENTRY" >>$SERVICES
  1640.     fi
  1641. fi
  1642.  
  1643. #
  1644. # Check that for servers being started at system boot.
  1645. #
  1646. if onServer; then
  1647.     signalINETD=no
  1648.     if [ -f /etc/init.d/hylafax ]; then
  1649.     true                    # started by init at boot time
  1650.     elif [ -f $INETDCONF ]; then
  1651.     E="hylafax    stream    tcp    nowait    $FAX    $DIR_LIBEXEC/hfaxd    hfaxd -I"
  1652.     editInetdConf()
  1653.     {
  1654.         ed - $INETDCONF<<EOF
  1655. /^hylafax[     ]*stream[     ]*tcp/d
  1656. a
  1657. $E
  1658. .
  1659. w
  1660. q
  1661. EOF
  1662.         if [ $? != 0 ]; then
  1663.         cat<<EOF
  1664.  
  1665. FATAL ERROR: Unable to correct HylaFAX entry in $INETDCONF!
  1666.  
  1667. We were unable to edit the $INETDCONF file to correct the entry
  1668. for starting up the HylaFAX client-server protocol process.  You
  1669. must manually correct this entry so that it reads:
  1670.  
  1671. $E
  1672.  
  1673. and then rerun faxsetup.
  1674.  
  1675. EOF
  1676.         boom
  1677.         fi
  1678.     }
  1679.     eval `$GREP '^hylafax[     ]*stream[     ]*tcp' $INETDCONF | \
  1680.         $AWK -F'[     ]+' '{ print "F=" $6 "; U=" $5 }' 2>/dev/null`
  1681.     if [ -z "$F" -a -z "$U" ]; then
  1682.         cat<<EOF
  1683.  
  1684.  
  1685. There is no entry for the hylafax service in $INETDCONF.
  1686. The HylaFAX client-server protocol process can be setup to run
  1687. standalone or started by the inetd program.  A standalone setup
  1688. is preferred for performance reasons, especially if hfaxd is to
  1689. support multiple protocols (e.g. SNPP); however it may require
  1690. manual setup if your operating system does not have a System-V
  1691. style init program.
  1692.  
  1693. EOF
  1694.         prompt "Should an entry be added to $INETDCONF [no]?"; read x
  1695.         if [ "$x" = y -o "$x" = yes ]; then
  1696.         echo "$E" >>$INETDCONF;
  1697.         signalINETD=yes
  1698.         fi
  1699.     else
  1700.         if [ "$F" != $DIR_LIBEXEC/hfaxd ]; then
  1701.         cat<<EOF
  1702.  
  1703.  
  1704. Warning: $INETDCONF is setup wrong!
  1705.  
  1706. The $INETDCONF file is setup to start $F
  1707. instead of $DIR_LIBEXEC/hfaxd.  You will need to correct
  1708. this before client requests to submit jobs will be properly serviced.
  1709.  
  1710. EOF
  1711.         prompt "Should the entry in $INETDCONF be corrected [yes]?"; read x
  1712.         isOK "$x" && editInetdConf
  1713.         fi
  1714.         if [ "$U" != $FAX ]; then
  1715.         cat<<EOF
  1716.  
  1717.  
  1718. Warning: $INETDCONF is setup wrong!
  1719.  
  1720. Warning, the HylaFAX entry is setup so that $F is run by the
  1721. $U user instead of the $FAX user.  This must be corrected
  1722. before client requests to submit jobs will be properly serviced.
  1723.  
  1724. EOF
  1725.         prompt "Should the entry in $INETDCONF be corrected [yes]?"; read x
  1726.         isOK "$x" && editInetdConf
  1727.         fi
  1728.     fi
  1729.     else
  1730.     cat<<EOF
  1731.  
  1732.  
  1733. Warning: Don't know how to startup HylaFAX servers!
  1734.  
  1735. No $INETDCONF file was found and the System V boot script
  1736. that starts up the HylaFAX server processes was also not present.
  1737. You will need to manually arrange for the various HylaFAX servers
  1738. to be started up on your system when it is booted multi-user. 
  1739. Specifically you will need to start the faxq and hfaxd programs and
  1740. any faxgetty processes that are to service inbound calls on modems.
  1741.  
  1742. EOF
  1743.     fi
  1744. fi
  1745.  
  1746. #
  1747. # Check for a FaxMaster entry for sending mail.
  1748. #
  1749. if onServer; then
  1750.     x=`(ypcat -k aliases) 2>/dev/null | $GREP -i '^faxmaster'` 2>/dev/null
  1751.     if [ -z "$x" -a -f $ALIASES ]; then
  1752.     x=`$GREP -i '^faxmaster' $ALIASES`
  1753.     fi
  1754.     if [ -z "$x" ]; then
  1755.     cat<<-EOF
  1756.  
  1757.  
  1758.     There does not appear to be an entry for the FaxMaster either in
  1759.     the YP/NIS database or in the $ALIASES file.  The
  1760.     FaxMaster is the primary point of contact for HylaFAX problems. 
  1761.     The HylaFAX client-server protocol server identifies this alias as
  1762.     the place to register complaints and HylaFAX directs automatic mail
  1763.     messages to this user when problems are identified on a server
  1764.     machine or when the routine server maintainence scripts are run
  1765.     (e.g. faxcron).
  1766.  
  1767.     EOF
  1768.     prompt "Should an entry be added for the FaxMaster to $ALIASES [yes]?"
  1769.     read x
  1770.     if isOK $x; then
  1771.         promptForNonNullStringParameter "${USER:-root}" \
  1772.            "Users to receive fax-related mail"
  1773.         (echo "# alias for notification messages from HylaFAX servers";
  1774.          echo "FaxMaster: $param") >>$ALIASES
  1775.         if newaliases 2>/dev/null; then
  1776.         echo "Rebuilt $ALIASES database."
  1777.         else
  1778.         # could be a SCO machine running mmdf
  1779.         if test -x /usr/mmdf/table/dbmbuild ; then
  1780.             su mmdf -c "/usr/mmdf/table/dbmbuild"
  1781.         else
  1782.             echo "Can not find newaliases to rebuild $ALIASES;"
  1783.             echo "you will have to do it yourself."
  1784.         fi
  1785.         fi
  1786.     fi
  1787.     fi
  1788. fi
  1789.  
  1790. #
  1791. # Emit shell functions required by faxaddmodem.
  1792. #
  1793. if onServer; then
  1794.     STTYCMD=`findApp stty $PATH`
  1795.     (dumpTTYFuncs; dumpSTTYFuncs; dumpOtherModemFuncs)>&5
  1796.     $RM etc/setup.modem
  1797.     $MV etc/setup.tmp etc/setup.modem
  1798.     $CHMOD 444 etc/setup.modem
  1799.  
  1800.     $RM etc/setup.cache
  1801.     (echo '# Warning, this file was automatically generated by faxsetup'
  1802.      echo '# on' `date` "for ${USER:-$euid}"
  1803.      dumpvals |sort)> etc/setup.cache
  1804.     $CHMOD 444 etc/setup.cache
  1805.  
  1806.     Note ""
  1807.     Note "Modem support functions written to $DIR_SPOOL/etc/setup.modem."
  1808.     Note "Configuration parameters written to $DIR_SPOOL/etc/setup.cache."
  1809. fi
  1810.  
  1811. #
  1812. # Configuration parameters specific to scheduler operation.
  1813. # Required parameters are *always* emitted in the created
  1814. # configuration file; optional parameters are emitted
  1815. # only if the configured value differs from the default
  1816. # value known to be used by the server.
  1817. #
  1818. # NB: the order of some parameters is important; e.g.
  1819. #     DialStringRules must be after AreaCode and CountryCode.
  1820. #
  1821. RequiredSchedulerParameters="
  1822.     LogFacility
  1823.     CountryCode
  1824.     AreaCode
  1825.     LongDistancePrefix
  1826.     InternationalPrefix
  1827.     DialStringRules
  1828.     ServerTracing
  1829. "
  1830. OptionalSchedulerParameters="
  1831.     ContCoverPage
  1832.     ContCoverCmd
  1833.     DestControls
  1834.     MaxConcurrentJobs
  1835.     MaxDials
  1836.     MaxSendPages
  1837.     MaxTries
  1838.     ModemClass
  1839.     PostScriptTimeout
  1840.     PS2FaxCmd
  1841.     SendFaxCmd
  1842.     SendPageCmd
  1843.     SendUUCPCmd
  1844.     SessionTracing
  1845.     TimeOfDay
  1846.     Use2D
  1847. "
  1848. #
  1849. # NB: these defaults are set above
  1850. #
  1851. OptionalParameters="
  1852.     $OptionalSchedulerParameters
  1853.     JobReqOther
  1854.     NotifyCmd
  1855.     UUCPLockDir
  1856.     UUCPLockTimeout
  1857.     UUCPLockType
  1858. "
  1859. SchedulerParameters="
  1860.     $RequiredSchedulerParameters
  1861.     $OptionalParameters
  1862. "
  1863.  
  1864. #
  1865. # Echo the configuration lines for those scheduler parameters
  1866. # whose value is different from the default value.  Note
  1867. # that we handle the case where there is embedded whitespace
  1868. # by enclosing the parameter value in quotes.
  1869. #
  1870. echoSchedulerParameters()
  1871. {
  1872.     (for i in $RequiredSchedulerParameters; do
  1873.     eval echo \"$i:\$$i:\"
  1874.      done
  1875.      for i in $OptionalSchedulerParameters; do
  1876.     eval echo \"$i:\$$i:\$default$i\"
  1877.      done) | $AWK -F: '
  1878. function p(tag, value)
  1879. {
  1880.     tabs = substr("\t\t\t", 1, 3-int((length(tag)+1)/8));
  1881.     if (match(value, "^[^\"].*[ ]") == 0)
  1882.     printf "%s:%s%s\n", tag, tabs, value
  1883.     else
  1884.     printf "%s:%s\"%s\"\n", tag, tabs, value
  1885. }
  1886. $2 != $3{ p($1, $2) }'
  1887. }
  1888.  
  1889. #
  1890. # Print the current server configuration parameters.
  1891. #
  1892. printSchedulerConfig()
  1893. {
  1894.     (for i in $SchedulerParameters; do
  1895.     eval echo \"$i:\$$i:\$default$i\"
  1896.     done) | $AWK -F: '
  1897. function p(tag, value)
  1898. {
  1899.     tabs = substr("\t\t\t", 1, 3-int((length(tag)+1)/8));
  1900.     printf "%s:%s%s\n", tag, tabs, value
  1901. }
  1902. BEGIN    { printf "\nThe non-default scheduler parameters are:\n\n" }
  1903. $2 != $3{ p($1, $2) }
  1904. END    { printf "\n" }'
  1905. }
  1906.  
  1907. checkForLocalFile()
  1908. {
  1909.     f="`echo $1 | $SED 's/\"//g'`"
  1910.     if [ ! -f $DIR_SPOOL/$f ]; then
  1911.     cat<<EOF
  1912.  
  1913. Warning, the $2 file,
  1914.  
  1915.     $DIR_SPOOL/$f
  1916.  
  1917. does not exist, or is not a plain file.  This file must
  1918. reside in the $DIR_SPOOL directory tree.
  1919. EOF
  1920.     ok=no;
  1921.     fi
  1922. }
  1923.  
  1924. isNotOK()
  1925. {
  1926.     x="$1"
  1927.     test "$x" != y -a "$x" != yes
  1928. }
  1929.  
  1930. CONFIG=$DIR_SPOOL/etc/config        # faxq config file
  1931. if onServer; then
  1932.     if [ ! -f $CONFIG ]; then
  1933.     for i in $SchedulerParameters; do
  1934.         eval $i=\$default$i
  1935.     done
  1936.     echo ""
  1937.     echo "No scheduler config file exists, creating one from scratch."
  1938.     ok=prompt                # prompt for parameters
  1939.  
  1940.     PROMPTS=/tmp/faxpr$$
  1941.     JUNK="$JUNK $PROMPTS"
  1942.     $RM $PROMPTS
  1943.  
  1944.     while true; do
  1945.         if [ "$ok" != skip ]; then
  1946.         test -f $PROMPTS || compilePrompts>$PROMPTS<<EOF
  1947. #    CountryCode        Country code
  1948. #    AreaCode        Area code
  1949. #    LongDistancePrefix    Long distance dialing prefix
  1950. #    InternationalPrefix    International dialing prefix
  1951. NNS    DialStringRules        Dial string rules file (relative to $DIR_SPOOL)
  1952. C#    ServerTracing        Tracing during normal server operation
  1953. C#    SessionTracing        \
  1954.     Default tracing during send and receive sessions
  1955. S    ContCoverPage        Continuation cover page (relative to $DIR_SPOOL)
  1956. C#    PostScriptTimeout    \
  1957.     Timeout when converting PostScript documents (secs)
  1958. C#    MaxConcurrentJobs    \
  1959.     Maximum number of concurrent jobs to a destination
  1960. S    ModemClass        Define a class of modems
  1961. S    TimeOfDay        Time of day restrictions for outbound jobs
  1962. S    DestControls        \
  1963.     Pathname of destination controls file (relative to $DIR_SPOOL)
  1964. C#    UUCPLockTimeout        \
  1965.     Timeout before purging a stale UUCP lock file (secs)
  1966. C#    MaxSendPages        Max number of pages to permit in an outbound job
  1967. S    LogFacility        Syslog facility name for ServerTracing messages
  1968. EOF
  1969.         . $PROMPTS
  1970.         fi
  1971.         checkForLocalFile $DialStringRules "dial string rules"
  1972.         if [ "$DestControls" != "" -a "$DestControls" != '""' ]; then
  1973.         checkForLocalFile $DestControls "destination controls";
  1974.         fi
  1975.         printSchedulerConfig; prompt "Are these ok [yes]?"; read ok
  1976.         isOK "$ok" && break
  1977.     done
  1978.  
  1979.     #
  1980.     # All done with the prompting; edit up a config file!
  1981.     #
  1982.     echo ""
  1983.     echo "Creating new configuration file $CONFIG..."
  1984.     echoSchedulerParameters >$CONFIG 2>/dev/null
  1985.     test -s $CONFIG || {
  1986.         JUNK="$JUNK $CONFIG"        # clobber on exit
  1987.         cat<<EOF
  1988.  
  1989. FATAL ERROR: Problem writing $CONFIG!
  1990.  
  1991. Sorry, something went wrong writing the new scheduler configuration
  1992. file.  Check to make sure there is sufficient disk space and rerun
  1993. this script.
  1994.  
  1995. EOF
  1996.         boom
  1997.     }
  1998.     $CHOWN $faxUID $CONFIG; $CHGRP $faxGID $CONFIG
  1999.     $CHMOD 644 $CONFIG
  2000.     fi
  2001. fi
  2002.  
  2003. #
  2004. # Startup/restart server processes.
  2005. #
  2006. if onServer; then
  2007.     echo ""
  2008.     echo "Restarting HylaFAX server processes."
  2009.  
  2010.     findproc()
  2011.     {
  2012.     # NB: ps ax should give an error on System V, so we try it first!
  2013.     pid="`ps ax 2>/dev/null | $AWK \"\
  2014.         /[\/ (]$1[ )]/    {print \\$1;}
  2015.         /[\/ ]$1\$/    {print \\$1;}\"`"
  2016.     test "$pid" ||
  2017.         pid="`ps -e 2>/dev/null | $AWK \"/ $1[ ]*\$/ {print \\$1;}\"`"
  2018.     echo "$pid"
  2019.     }
  2020.  
  2021.     HFAXD="`findproc hfaxd`"
  2022. #    if [ "$HFAXD" ]; then
  2023. #    fi
  2024.     FAXD="`findproc faxd`"
  2025.     if [ "$FAXD" ]; then
  2026.     echo ""
  2027.     echo "You seem to be running FlexFAX (there are faxd processes)."
  2028.     prompt "Is it ok to terminate these processes ($FAXD) [yes]?"; read x
  2029.     if isOK "$x"; then
  2030.         if kill $FAXD; then
  2031.         echo "Sent a SIGTERM to processes $FAXD."
  2032.         else
  2033.         echo "Unable to send a SIGTERM to processes $FAXD."
  2034.         fi
  2035.         while true; do
  2036.         for delay in 1 1 2 2 5 5; do
  2037.             FAXD="`findproc faxd`"
  2038.             test "$FAXD" || break
  2039.             sleep $delay
  2040.         done
  2041.         test -z "$FAXD" && break
  2042.         cat<<EOF
  2043.  
  2044. Warning: faxd is still running!
  2045.  
  2046. Something is hung.  The command
  2047.  
  2048.     kill $FAXD
  2049.     
  2050. did not terminate the faxd processes as expected.
  2051. EOF
  2052.         prompt "Should we continue to wait [no]?"; read x
  2053.         isNotOK "$x" && break
  2054.         done
  2055.     fi
  2056.     fi
  2057.     FAXQ="`findproc faxq`"
  2058.     if [ "$FAXQ" ]; then
  2059.     cat<<EOF
  2060.  
  2061. You have a HylaFAX scheduler process running.  faxq will be
  2062. restarted shortly, as soon as some other work has been completed.
  2063. EOF
  2064.     prompt "Can I terminate this faxq process ($FAXQ) [yes]?";
  2065.     read x
  2066.     if isOK "$x" ]; then
  2067.         $DIR_SBIN/faxquit >/dev/null 2>&1
  2068.         while true; do
  2069.         for delay in 1 1 2 2 5 5; do
  2070.             FAXQ="`findproc faxq`"
  2071.             test "$FAXQ" || break
  2072.             sleep $delay
  2073.         done
  2074.         test -z "$FAXQ" && break
  2075.         pids=
  2076.         for p in faxsend pagesend; do
  2077.             pids="${pids}`findproc $p`"
  2078.         done
  2079.         if [ "$pids" ]; then
  2080.             cat<<EOF
  2081.  
  2082. Warning: faxq is busy with outbound jobs!
  2083.  
  2084. faxq did not terminate in response to the faxquit command because
  2085. there are subprocesses actively processing outbound jobs.
  2086. EOF
  2087.             prompt "Should we continue to wait [yes]?"; read x
  2088.             isOK "$x" || break
  2089.         else
  2090.             cat<<EOF
  2091.  
  2092. Warning: faxq is still running for some reason!
  2093.  
  2094. Something is hung, faxq did not terminate in response to the faxquit
  2095. command.  There do not appear to be any faxsend or pagesend subprocesses
  2096. actively handling outbound jobs so the reason for it running is unknown.
  2097. EOF
  2098.             prompt "Should we continue to wait [no]?"; read x
  2099.             isNotOK "$x" && break
  2100.         fi
  2101.         done
  2102.     fi
  2103.     fi
  2104.  
  2105.     if [ "$FAXQ" -o "$FAXD" ]; then
  2106.     cat<<EOF
  2107.  
  2108. FATAL ERROR: Old server processes still running!
  2109.  
  2110. One or more old server processes are still running.  It is not wise
  2111. to start new server processes while old processes are running because
  2112. their actions might conflict.  You need to terminate the existing
  2113. processes and rerun this script or manually startup the new HylaFAX
  2114. server processes.
  2115.  
  2116. EOF
  2117.     boom
  2118.     fi
  2119.  
  2120.     if [ "$signalINETD" = yes ]; then
  2121.     INETD="`findproc inetd`"
  2122.     if [ "$INETD" ]; then
  2123.         if kill -HUP $INETD 2>/dev/null; then
  2124.         echo "Sent inetd a SIGHUP so that it re-reads the configuration file."
  2125.         else
  2126.         echo "Unable to send inetd a SIGHUP, you may need to do it yourself."
  2127.         fi
  2128.     else
  2129.         echo "Strange, you do not seem to have an inetd process running."
  2130.     fi
  2131.     fi
  2132.  
  2133.     prompt "Should I restart the HylaFAX server processes [yes]?"; read x
  2134.     if isOK "$x"; then
  2135.     echo ""
  2136.     if [ -x /etc/init.d/hylafax ]; then
  2137.         echo /etc/init.d/hylafax start
  2138.         /etc/init.d/hylafax start
  2139.     else
  2140.         echo $DIR_SBIN/faxq; $DIR_SBIN/faxq
  2141.     fi
  2142.     fi
  2143.  
  2144.     DEVS="`cd $DIR_SPOOL/etc; echo config.*`"
  2145.     if [ -z "$DEVS" -o "$DEVS" = 'config.*' ]; then
  2146.     cat<<EOF
  2147.  
  2148. You do not appear to have any modems configured for use.  Modems are
  2149. configured for use with HylaFAX with the faxaddmodem(1M) command.
  2150. EOF
  2151.     prompt "Do you want to run faxaddmodem to configure a modem [yes]?"; read x
  2152.     while isOK "$x"; do
  2153.          $DIR_SBIN/faxaddmodem
  2154.          prompt "Do you want to run faxaddmodem to configure another modem [yes]?"; read x
  2155.     done
  2156.     DEVS="`cd $DIR_SPOOL/etc; echo config.*`"
  2157.     fi
  2158.  
  2159.     if [ -n "$DEVS" -a "$DEVS" != 'config.*' ]; then
  2160.     FAXGETTY="`findproc faxgetty`"
  2161.     if [ "$FAXGETTY" ]; then
  2162.         cat<<EOF
  2163.  
  2164. Looks like you have some faxgetty processes running (PIDs are):
  2165.  
  2166.     $FAXGETTY
  2167.  
  2168. It is usually a good idea to restart these processes after running
  2169. faxsetup; especially if have just installed new software.  If these
  2170. processes are being started by init(1M) then sending each of them a
  2171. QUIT message with the faxquit command should cause them to be restarted.
  2172. EOF
  2173.         prompt "Is it ok to send a QUIT command to each process [yes]?"
  2174.         read x
  2175.         if isOK "$x"; then
  2176.         for x in $DEVS; do
  2177.             devid="`expr $x : 'config.\(.*\)'`"
  2178.             if [ -w $DIR_SPOOL/FIFO.$devid ]; then
  2179.             echo $DIR_SBIN/faxquit $devid
  2180.             $DIR_SBIN/faxquit $devid >/dev/null 2>&1
  2181.             fi
  2182.         done
  2183.         fi
  2184.     else
  2185.         if [ -f /etc/inittab ]; then
  2186.         FAXGETTY="`$GREP '[^#].*:respawn:faxgetty.*' /etc/inittab`"
  2187.         elif [ -f /etc/ttys ]; then
  2188.         FAXGETTY="`$GREP '[^#].*faxgetty.*' /etc/ttys`"
  2189.         fi
  2190.         if [ "$FAXGETTY" ]; then
  2191.         cat<<EOF
  2192.  
  2193. You appear to have faxgetty setup to run on some tty lines but no faxgetty
  2194. processes were found running.  This might happen if you manually edited the
  2195. tty configuration file but did not notify init to re-read the file.
  2196.  
  2197. EOF
  2198.         prompt "Send init a SIGHUP so that it re-reads its configuration file [yes]?"
  2199.         read x
  2200.         if isOK "$x"; then
  2201.             init="`findproc init`"
  2202.             if [ "$init" ]; then
  2203.             if kill -HUP $init; then
  2204.                 echo "Sent init a SIGHUP; the faxgetty processes should be started."
  2205.             else
  2206.                 echo "Unable to send init a SIGHUP; you may need to do this yourself."
  2207.             fi
  2208.             else
  2209.             echo "Strange, you do not seem to have an init process running!"
  2210.             fi
  2211.         fi
  2212.         else
  2213.         cat<<EOF
  2214.  
  2215. You do not appear to be using faxgetty to notify the HylaFAX scheduler
  2216. about new modems and/or their status.  This means that you must use the
  2217. faxmodem program to inform the new faxq process about the modems you
  2218. want to have scheduled by HylaFAX.  Beware that if you have modems that
  2219. require non-default capabilities specified to faxmodem then you should
  2220. read faxmodem(1M) manual page and do this work yourself (since this
  2221. script is not intelligent enough to automatically figure out the modem
  2222. capabilities and supply the appropriate arguments).
  2223.  
  2224. EOF
  2225.         prompt "Should I run faxmodem for each configured modem [yes]?"
  2226.         read x
  2227.         if isOK "$x"; then
  2228.             for x in $DEVS; do
  2229.             devid="`expr $x : 'config.\(.*\)'`"
  2230.             if [ -w $DIR_SPOOL/FIFO.$devid ]; then
  2231.                 echo $DIR_SBIN/faxmodem $devid
  2232.                 $DIR_SBIN/faxmodem $devid >/dev/null 2>&1
  2233.             fi
  2234.             done
  2235.         fi
  2236.         fi
  2237.     fi
  2238.     fi
  2239. fi
  2240.  
  2241. Note ""
  2242. Note "Done verifying system setup."
  2243.  
  2244. if onServer; then
  2245.     $RM $JUNK
  2246. fi
  2247. exit 0
  2248.